#include "book_add_dialog.h"
#include "ui_book_add_dialog.h"
#include "QDebug"
book_add_Dialog::book_add_Dialog(QWidget *parent) :
    QDialog(parent),
    flag(false),
    ui(new Ui::book_add_Dialog)
{
    ui->setupUi(this);
    ui->pushButton_OK->setEnabled(false);
}

book_add_Dialog::~book_add_Dialog()
{
    delete ui;
}

void book_add_Dialog::closeEvent(QCloseEvent *event)
{
    this->close();
}

void book_add_Dialog::on_pushButton_OK_clicked()
{
    flag = true;

    book.append(ui->lineEdit_number->text());
    book.append(ui->lineEdit_ISBN->text());
    book.append(ui->lineEdit_name->text());
    book.append(ui->lineEdit_writer->text());
//    book.append(QString::number(ui->lineEdit_price->text().toFloat(),'f',2));
    book.append(ui->lineEdit_price->text());
    book.append(QString::number(ui->spinBox_num->value()));
    book.append(ui->dateEdit_PublishTime->date().toString("yyyy年MM月"));
    book.append(ui->comboBox_PublishUnit->currentText());

//    qDebug()<<book;
    this->close();
}

void book_add_Dialog::on_lineEdit_number_textChanged(const QString &arg1)
{
    if(!arg1.isEmpty()) ui->pushButton_OK->setEnabled(true);
}

void book_add_Dialog::on_pushButton_2_clicked()
{
    this->close();
}
